import Vue from 'vue'
import VueRouter from 'vue-router'

//导入需要使用的组件
//1.首页的路由
import Films from "../views/Film/Films.vue"
import NowPlaying from "../views/Film/NowPlaying.vue"
import ComingSoon from "../views/Film/ComingSoon.vue"
import Detail from "../views/Film/Detail.vue"
//影院模块的路由
import Cinemas from "../views/Cinema/Cinemas.vue"
//城市列表的路由
import City from "../views/City/City.vue"
//登录模块的路由
import Center from "../views/Center/Center.vue"
import Login from "../views/Center/Login.vue"

Vue.use(VueRouter)

const routes = [
 //1.路由：请求地址与响应资源的对应关系
 //2.实现步骤
 //a：创建地址对应组件，组件暂时不考虑布局等因素，输出不同的内容即可
 //b:导入组件
 //c：书写的路由规则暂不拆分
 //d：拆分成模块化的形式

 //2.偷懒 添加一个路由的重定向
 {path: "/",redirect: "/films/NowPlaying"},

 //1.电影模块的路由
 { path: '/films', component: Films,
 //指定嵌套路由
 children: [
   { path: 'nowPlaying', component: NowPlaying },
   {path: 'comingsoon',component:ComingSoon}
           ]
 },
    //电影详情页
   { path: '/film/:film_id', component: Detail },
   //影院模块
   { path: '/cinemas', component: Cinemas },
   //城市列表
   { path: '/city', component: City },
   //登录
   { path: '/center', component: Center },
   { path: '/login', component: Login }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
